package com.redisdemo.job;

import com.redisdemo.common.RedisConstant;
import com.redisdemo.domain.Message;
import com.redisdemo.utlis.RedisUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <h3>redisDemo</h3>
 * <p>定时发送消息</p>
 *
 * @author gdw
 * @since 2024-06-25 16:50:28
 */
public class SendMessageJob  implements Job {
    @Autowired
    private RedisUtils redisUtils;
    /**
     * 发送消息
     * @param context
     * @throws JobExecutionException
     */
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        Message build = Message.builder().sendId(1).sendName("小古").receiveId(2).receiveName("小梁").message("大傻逼，不给我爆金币").build();
        redisUtils.lSet(RedisConstant.REDIS_LIST_MESSAGE, build);
        System.out.println("=========================");
        System.out.println(build.getSendName()+"向用户："+build.getReceiveName()+"发送了一条消息");
    }
}
